package com.lijy.object;

import java.util.Random;

public class ConstructorTest {
    public static void main(String[] args) {
        Employees[] staff = new Employees[3];
        staff[0] = new Employees("Harry", 1000);
        staff[1] = new Employees(6000);
        staff[2] = new Employees();

        for (Employees e : staff) {
            System.out.println("name= " + e.getName() + ", id= "
                    + e.getId() + ",salary= " + e.getSalary() );
        }

    }
}

class Employees {
    private static int nextId;

    private int id;
    private String name = "";
    private double salary;

    static
    {
        Random generator = new Random();
        nextId = generator.nextInt(10000);
    }

    {
        id = nextId;
        nextId++;
    }

    public Employees() {
    }

    public Employees(String name, double salary) {
        this.name = name;
        this.salary = salary;
    }

    public Employees(double salary) {
        this("Employee # ", salary);
    }

    public int getId() {
        return id;
    }

    public String getName() {
        return name;
    }

    public double getSalary() {
        return salary;
    }
}
